<template>
	<view class="mainpadding" style="padding-top: 0;">
		<view class="flexleft flex_wrap">
			<view class="margin_right2 margin_top2" :class="status==0?'yixbtn':'wxbtn'" @click="status=0;init()">全部（{{dataAll.comment_num}}）</view>
			<view class="margin_right2 margin_top2" v-if="dataAll.comment_wz_num" :class="status==1?'yixbtn':'wxbtn'" @click="status=1;init()">文字（{{dataAll.comment_wz_num}}）</view>
			<view class="margin_right2 margin_top2" v-if="dataAll.comment_dt_num" :class="status==2?'yixbtn':'wxbtn'" @click="status=2;init()">带图（{{dataAll.comment_dt_num}}）</view>
			<view class="margin_right2 margin_top2" v-if="dataAll.comment_hp_num" :class="status==3?'yixbtn':'wxbtn'" @click="status=3;init()">好评（{{dataAll.comment_hp_num}}）</view>
			<view class="margin_right2 margin_top2" v-if="dataAll.comment_cp_num" :class="status==4?'yixbtn':'wxbtn'" @click="status=4;init()">差评（{{dataAll.comment_cp_num}}）</view>
		</view>
		<view class="flextop margin_top xiahuaxian" v-for="item in list.data" :key="item.id">
			<image class="touxiang" :src="item.user.avatar_text" mode=""></image>
			<view class="" style="width: 86%;">
				<view class="flexbetween">
					<view class="">
						<view class="ershiba">{{item.user.nickname}}</view>
						<view class="flexleft margin_top1">
							<view class="margin_right1"v-for="(ite,ind) in item.star" :key="ind" >
								<u-icon name="star-fill" color="#2361FF" ></u-icon>
							</view>
							<!-- <view class="smalltext xiaohui">中等满意</view> -->
						</view>
					</view>
					<view class="smalltext xiaohui">{{httpRequest.timereturn(item.createtime*1000)}}</view>
				</view>
				<view class="ershil margin_top2">{{item.content}}</view>
				<view class="flexleft flex_wrap">
					<view class="flexcenter sanshis margin_top2" v-for="(ite,ind) in item.images_text" :key="ind" @click="lbtpriview(ind,item.images_text)">
						<image class="pjtp" :src="ite" mode=""></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				httpRequest,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				status:0,
				listid:"",
				dataAll:{}
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
			this.getDetail()
		},
		methods: {
			getDetail() { //获取商品分类
				httpRequest.request('/api/goods/goodsDetail', 'GET', {
					goods_id: this.listid
				}).then(res => {
					this.dataAll = res.data
				}).catch(err => {})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					status: this.status,
					goods_id:this.listid
				}
				let url = '/api/goods/goodsComment'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
					console.log(this.list, "金戈里");
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pjtp {
		width: 160rpx;
		height: 160rpx;
		background: #FBFCFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.touxiang {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}

	.wxbtn {
		padding: 13rpx 20rpx;
		background: #F6F9FE;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		border: 1rpx solid #B5BFDA;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #150E33;
	}

	.yixbtn {
		padding: 13rpx 20rpx;
		background: rgba(35, 97, 255, 0.1);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		border: 1rpx solid #2361FF;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #2361FF;
	}
</style>